﻿<Window x:Class="Road3App.Views.MainView"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:uc="clr-namespace:Road3App.Views.UserControls"
        Title="Road Network" Height="600" Width="800" MinHeight="300" MinWidth="500"
        ResizeMode="CanResizeWithGrip">
    
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="auto"/>
            <RowDefinition Height="auto"/>
            <RowDefinition/>
            <RowDefinition Height="auto"/>
        </Grid.RowDefinitions>

        <Menu IsMainMenu="True"
              Grid.Row="0">
            <MenuItem Header="File">
                <MenuItem Header="New" Name="NewMI"/>
                <MenuItem Header="Open" Name="OpenMI"/>
                <MenuItem Header="Save" Name="SaveMI"/>
                <MenuItem Header="Save as" Name="SaveAsMI"/>
                <Separator/>
                <MenuItem Header="Exit" Name="ExitMI"/>
            </MenuItem>
            <MenuItem Header="View" Visibility="Collapsed"></MenuItem>
            <MenuItem Header="Help">
                <MenuItem Header="About" Name="AboutMI"/>
            </MenuItem>
        </Menu>

        <ToolBarTray Grid.Row="1">
            <ToolBar>
                <Button ToolTip="Road" Name="AddRoadButton">
                    <Grid Width="30" Height="30">
                        <Rectangle Width="30" Height="20" Fill="LightGray" Stroke="Black"/>
                        <Line X1="1" X2="29" Y1="15" Y2="15" Stroke="White" StrokeThickness="3" StrokeDashArray="2,2"/>
                    </Grid>
                </Button>
                <Button ToolTip="Crossroad" Name="AddCrossroadButton">
                    <Grid Width="30" Height="30">
                        <Path Stroke="Black" Fill="LightGray">
                            <Path.Data>
                                <CombinedGeometry GeometryCombineMode="Union">
                                    <CombinedGeometry.Geometry1>
                                        <RectangleGeometry Rect="10,0,10,30"/>
                                    </CombinedGeometry.Geometry1>
                                    <CombinedGeometry.Geometry2>
                                        <RectangleGeometry Rect="0,10,30,10"/>
                                    </CombinedGeometry.Geometry2>
                                </CombinedGeometry>
                            </Path.Data>
                        </Path>
                        <Line X1="15" X2="15" Y1="1" Y2="10" Stroke="White" StrokeThickness="2" StrokeDashArray="2,2" StrokeDashOffset="1"/>
                        <Line X1="1" X2="10" Y1="15" Y2="15" Stroke="White" StrokeThickness="2" StrokeDashArray="2,2" StrokeDashOffset="1"/>
                        <Line X1="15" X2="15" Y1="20" Y2="29" Stroke="White" StrokeThickness="2" StrokeDashArray="2,2" StrokeDashOffset="1" />
                        <Line X1="20" X2="29" Y1="15" Y2="15" Stroke="White" StrokeThickness="2" StrokeDashArray="2,2" StrokeDashOffset="1" />
                    </Grid>
                </Button>
                <Button ToolTip="Vehicle Generator" Name="AddVehGenButton">
                    <Grid Width="30" Height="30">
                        <Ellipse Width="25" Height="25" Fill="White" Stroke="Black" />
                        <TextBlock Text="0.5" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                    </Grid>
                </Button>
                <ToggleButton ToolTip="Connector" Name="AddConnectorButton">
                    <Grid Width="30" Height="30">
                        <Path Stroke="Black" StrokeThickness="1" Data="M 5,25 C 12,0 18,30 25,10"/>
                        <Ellipse Width="4" Height="4" Fill="Black" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="3,23,0,0"/>
                        <Ellipse Width="4" Height="4" Fill="Black" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="23,8,0,0"/>
                    </Grid>
                </ToggleButton>
                <Separator Visibility="Collapsed"/>
                <Button ToolTip="Edit" Name="EditButton" Content="Edit"  Width="30" Height="30" IsEnabled="False" Visibility="Collapsed"/>
                <Separator Visibility="Collapsed"/>
                <Button ToolTip="Remove" Name="RemoveButton" IsEnabled="False" Visibility="Collapsed">
                    <Grid Width="30" Height="30">
                        <Rectangle Width="5" Height="30" Fill="DarkRed" RadiusX="3" RadiusY="3"
                                   RenderTransformOrigin="0.5,0.5">
                            <Rectangle.RenderTransform>
                                <RotateTransform Angle="45"/>
                            </Rectangle.RenderTransform>
                        </Rectangle>
                        <Rectangle Width="5" Height="30" Fill="DarkRed" RadiusX="3" RadiusY="3"
                                   RenderTransformOrigin="0.5,0.5">
                            <Rectangle.RenderTransform>
                                <RotateTransform Angle="-45"/>
                            </Rectangle.RenderTransform>
                        </Rectangle>
                    </Grid>
                </Button>
            </ToolBar>
            <ToolBar>
                <ToolBar.Resources>
                    
                    <Grid Width="30" Height="30" x:Key="StartGrid">
                        <Polygon Fill="Black" Stroke="Black" Points="7.5,5 7.5,25 22.5,15"/>
                    </Grid>

                    <Grid Width="30" Height="30" x:Key="PauseGrid">
                        <StackPanel Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Center">
                            <Rectangle Width="5" Height="20" Fill="Black" Stroke="Black"/>
                            <Rectangle Width="5"/>
                            <Rectangle Width="5" Height="20" Fill="Black" Stroke="Black"/>
                        </StackPanel>
                    </Grid>

                    <Style TargetType="ToggleButton" x:Key="StartPauseStyle">
                        <Style.Triggers>
                            <Trigger Property="IsChecked" Value="True">
                                <Setter Property="Content" Value="{StaticResource PauseGrid}"/>
                            </Trigger>
                            <Trigger Property="IsChecked" Value="False">
                                <Setter Property="Content" Value="{StaticResource StartGrid}"/>
                            </Trigger>
                        </Style.Triggers>
                    </Style>

                </ToolBar.Resources>

                <Button Content="Init" Name="InitButton" Width="30" Height="30" Visibility="Collapsed"/>
                <ToggleButton Name="StartStopButton" ToolTip="Start/Pause" Style="{StaticResource StartPauseStyle}"/>
                <Separator/>
                <Slider Name="ZoomSlider" Value="1" Minimum="0.5" Maximum="3" 
                        IsSnapToTickEnabled="True" Ticks="0.5,0.6,0.7,0.8,0.9,1,1.5,2,2.5,3" 
                        Width="100" VerticalAlignment="Center" HorizontalAlignment="Center"/>
                <TextBlock Text="{Binding Path=Value, ElementName=ZoomSlider, StringFormat={}{0:0.0x}}"
                           VerticalAlignment="Center" HorizontalAlignment="Center"/>
            </ToolBar>
        </ToolBarTray>

        <Grid Grid.Row="2">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="3*"/>
                <ColumnDefinition Width="0"/>
            </Grid.ColumnDefinitions>

            <ScrollViewer Grid.Column="0" Margin="10"
                          HorizontalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Visible">
                <uc:RoadNetworkUC x:Name="RoadNetwork" DataContext="{Binding ContainerCollection}"
                                  RenderTransformOrigin="0.5,0.5">
                    <uc:RoadNetworkUC.LayoutTransform>
                        <ScaleTransform ScaleX="{Binding Path=Value, ElementName=ZoomSlider}"
                                        ScaleY="{Binding Path=Value, ElementName=ZoomSlider}"/>
                    </uc:RoadNetworkUC.LayoutTransform>
                </uc:RoadNetworkUC>
            </ScrollViewer>

            <GridSplitter Grid.Column="1" Width="5" HorizontalAlignment="Left" Visibility="Collapsed">
                <GridSplitter.Background>
                    <LinearGradientBrush>
                        <GradientStop Color="Transparent" Offset="0"/>
                        <GradientStop Color="#FFF0F0F0" Offset="0.3"/>
                        <GradientStop Color="#FFF0F0F0" Offset="1"/>
                    </LinearGradientBrush>
                </GridSplitter.Background>
            </GridSplitter>

            <TabControl Grid.Column="1" Margin="15,10,10,10" TabStripPlacement="Bottom" Visibility="Collapsed">
                <TabItem Header="Info"/>
                <TabItem Header="Second"/>
            </TabControl>

        </Grid>

        <StatusBar Grid.Row="3">
            <StatusBarItem Content=""/>
        </StatusBar>

    </Grid>
</Window>
